home *** CD-ROM | disk | FTP | other *** search
- /*
- MacTCPExtras.c
-
- These are extra little chunks of code needed by routines in the library. By putting them here
- they can be used by the app, too.
-
- 01/28/94: 1.0 alpha - dn
- 06/01/95: 1.1 alpha - dn - Modified to use the Universal Headers.
- 11/28/94 mc - Converted to CodeWarrior
- 12/04/95 dn - Prep'd for Apprentice 4
- */
-
- #include <MyTCPIncludes.h>
-
- #include <Traps.h>
- #include <GestaltEqu.h>
- #include <Folders.h>
- #include <OSUtils.h>
- #include <Devices.h>
-
- /*
- StrLen
-
- A quick and dirty strlen routine.
- */
- short StrLen(char* cp){
- register short i=0;
- register char* c=cp;
-
- while (*c++)
- i++;
-
- return i;
- }
-
- /*
- MyC2PStr
-
- A quick C --> Pascal string converter.
- */
- StringPtr MyC2PStr(char* cstr){
- unsigned char len=StrLen(cstr);
-
- BlockMoveData((Ptr)cstr,(Ptr)(cstr+1),len);
- cstr[0]=len;
-
- return (StringPtr)cstr;
- }
-
- /*
- MyP2CStr
-
- A quick Pascal --> C string converter.
- */
- char* MyP2CStr(StringPtr pstr){
- unsigned char len=pstr[0];
-
- BlockMoveData((Ptr)(pstr+1),(Ptr)pstr,len);
- pstr[len]=0;
-
- return (char*)pstr;
- }
-
- /*
- MemSet
-
- A quick and dirty memset
- */
- void MemSet(register char* c,char ch,register long size){
- while (size--)
- *c++=ch;
- }
-
- /*
- SyncAsync
-
- General routine for doing a synchronous or asynchronous call. Does special error checking
- to ensure that the ParmBlkPtr is not nil.
- */
- OSErr SyncAsync(ParmBlkPtr pb,Boolean async){
- OSErr err;
-
- if (pb==(ParmBlkPtr)0)
- return nilParmBlkPtr;
-
- if (!async){
- pb->ioParam.ioCompletion=(IOCompletionUPP)0;
- err=PBControlSync((ParmBlkPtr)pb);
- } else {
- err=PBControlAsync((ParmBlkPtr)pb);
- }
-
- if (err==noErr)
- err=pb->ioParam.ioResult;
-
- return err;
- }
-
-
-
-
-
-